package deibay.client.commands;

import deibay.client.Command;
import deibay.client.Controller;
import deibay.datamodel.Item;
import deibay.messages.Message;
import deibay.messages.SendItemDetailsMsg;

public class SendItemDetailsCommand extends Command{

	public SendItemDetailsCommand(Controller controller, Message msg) {
		super(controller, msg);
	}

	@Override
	public void execute() {
		Item item = ((SendItemDetailsMsg)message).getItem();		
		controller.getBidderController().getViewItemDetails().setName(item.getName());
		controller.getBidderController().getViewItemDetails().setDescription(item.getDescription());
		controller.getBidderController().getViewItemDetails().setSeller(item.getSeller());
		controller.getBidderController().getViewItemDetails().setBidder(item.getBidder());
		if(item.getCategory()!=null)
			controller.getBidderController().getViewItemDetails().setCategory(item.getCategory().toString());
		controller.getBidderController().getViewItemDetails().setStartPrice(item.getStartPrice());
		controller.getBidderController().getViewItemDetails().setDeadline(item.getFinishTime());
		controller.getBidderController().getViewItemDetails().setActualPrice(item.getActualPrice());
		controller.getBidderController().getViewItemDetails().setID(item.getId());
		controller.getBidderController().getViewItemDetails().setBiddingActionEnabled(true);
		controller.getBidderController().getViewItemDetails().setNotifyActionEnabled(true);
	}

}
